<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<!-- ${modelDesc!} Mybatis Mapper -->
<mapper namespace="${modelPrefix!}${modelSuffix!}">
    <!-- 查询条件 -->
    ${queryCondition!}

    <!-- 插入 -->
    <insert id="insert" parameterType="${modelPrefix!}${modelSuffix!}">
        <![CDATA[
            ${insert!}
        ]]>
        <selectKey resultType="Long" keyProperty="id" order="AFTER">
            <![CDATA[ 
                SELECT LAST_INSERT_ID()  AS id
            ]]>
        </selectKey>
    </insert>

    <!-- 分页查询&过滤查询 -->
    <select id="select" parameterType="${modelPrefix!}${modelSuffix!}" resultType="${modelPrefix!}${modelSuffix!}">
        <![CDATA[
            ${select!} 
        ]]>
        <include refid="QueryConditionSql" />
        <![CDATA[
            ORDER BY CREATED_DATE DESC
        ]]>
    </select>

    <!-- 记录总数 -->
    <select id="count" parameterType="${modelPrefix!}${modelSuffix!}" resultType="Integer">
        <![CDATA[
            ${count!}
        ]]>
        <include refid="QueryConditionSql" />
    </select>

    <!-- 主键查询 -->
    <select id="selectByPK" parameterType="String" resultType="${modelPrefix!}${modelSuffix!}">
        <![CDATA[
            ${selectByPK!}
        ]]>
    </select>

    <!-- 删除 -->
    <delete id="delete" parameterType="String">
        <![CDATA[
            ${delete!}
        ]]>
    </delete>

    <!-- 更新 -->
    <update id="update" parameterType="${modelPrefix!}${modelSuffix!}">
        ${update!}
    </update>

    <!-- 更新所有 -->
    <update id="updateAll" parameterType="${modelPrefix!}${modelSuffix!}">
        <![CDATA[
            ${updateAll!}
        ]]>
    </update>
</mapper> 
